#pragma once
#include "base/core/chunk_pool.h"

template<class TYPE>
class ObjectPool : private ChunkPool 
{
public:
	ObjectPool(uint32_t count_in_block = 0, bool auto_free = true);
	virtual ~ObjectPool();

	TYPE* Alloc();
	bool  Free(TYPE* obj);
public:
	TYPE* AllocTrack(const char* file,
                     const char* func,
                     uint32_t line);
	bool  FreeTrack(TYPE* obj);

	uint32_t MemSize()
	{
		return mem_size_;
	}
};

#ifdef CHECK_MEM_LEAK
#define  MallocObj()        AllocTrack(__FILE__, __FUNCTION__, __LINE__)
#define  FreeObj            FreeTrack
#else
#define  MallocObj()        Alloc()
#define  FreeObj            Free
#endif  // CHECK_MEM_LEAK

#include "base/core/object_pool.hpp"
